package com.tarena.lbs.user.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.user.pojo.param.AdminLoginParam;
import com.tarena.lbs.user.pojo.param.AdminParam;
import com.tarena.lbs.user.pojo.query.AdminQuery;
import com.tarena.lbs.user.pojo.vo.AdminVO;
import com.tarena.lbs.user.pojo.vo.LoginVO;
import com.tarena.lbs.user.service.AdminService;
import com.tarena.lbs.user.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理和后台用户相关的业务接口
 */

@Slf4j
@RestController
@Tag(name = "后台用户接口", description = "处理和后台用户相关的业务接口")
public class AdminController {

    @Autowired
    private LoginService loginService;


    @Autowired
    private AdminService adminService;


    @Operation(summary = "管理员登录")
    @PostMapping("/passport/admin/login")
    public Result<LoginVO> adminLogin(AdminLoginParam param) throws BusinessException {
        log.debug("管理员登录业务处理,入参:{}",param);
        LoginVO vo = loginService.doLogin(param);
        log.debug("管理员登录成功，入参:{},出参:{}",param,vo);
        return new Result<>(vo);
    }


    @Operation(summary = "用户详情")
    @GetMapping("/admin/basic/role/detail")
    public Result<AdminVO> detail() throws BusinessException {
        log.debug("查询登录用户详情");
        AdminVO vo = adminService.detail();
        log.debug("查询登录用户详情成功，出参:{}",vo);
        return new Result<>(vo);
    }


    /**
     * 查询后台管理的 账号列表
     */
    @Operation(summary = "账号列表")
    @PostMapping("/admin/basic/role/list")
    public Result<PageResult<AdminVO>> pageList(@RequestBody AdminQuery query)
        throws BusinessException{
        PageResult<AdminVO> voPage = adminService.pageList(query);
        return new Result<>(voPage);
    }

    @Operation(summary = "账号保存")
    @PostMapping("/admin/basic/role/add")
    public Result<Void> save(@RequestBody AdminParam param)
        throws BusinessException{
        return null;
    }













































}